import Page
from Page import Map
from Base.Base import Base
from selenium.webdriver.common.by import By


class MapNavigatingPage(Base):
    """
    模拟导航中

    """

    def __init__(self, driver):
        Base.__init__(self, driver)

        # 左侧的home键
        self.navigating_home_btn = (By.XPATH, Map.RESOURCE_ID.format("rl_navigation_home"))

        # 左侧的返回键
        self.navigating_back_btn = (By.XPATH, Map.RESOURCE_ID.format('rl_navigation_back'))

        # 路线转向
        self.navigating_route_turn_btn = (By.XPATH, Map.RESOURCE_ID.format('rl_navigation_back'))

        # 路线剩余距离
        self.navigating_route_remaining_distance_text = (
            By.XPATH, Map.RESOURCE_ID.format("index_guidance_roate_distance_tv"))


        # 当前位置
        self.navigating_current_position_text = (By.XPATH, Map.RESOURCE_ID.format("index_guidance_roate_name_tv"))

        # 剩余距离提示
        self.navigating_remaining_distance_tip_text = (
            By.XPATH, Map.RESOURCE_ID.format("index_guidance_drive_information_prompt_tv"))

        # 剩余距离
        self.navigating_remaining_distance_text = (
            By.XPATH, Map.RESOURCE_ID.format("index_guidance_drive_information_tv"))

        # 路线提示
        self.navigating_route_reminder_img = (By.XPATH, Map.RESOURCE_ID.format("arlane_line_viewer"))

        # 关闭按钮
        self.navigating_close_btn = (By.XPATH, Map.RESOURCE_ID.format("bottom_function_simu_exit"))

        # 暂停按钮
        self.navigating_stop_btn = (By.XPATH, Map.RESOURCE_ID.format("index_simulation_navi_contorller_view_rl"))

        # 倍速
        self.navigating_double_speed_btn = (
            By.XPATH, Map.RESOURCE_ID.format("index_simulation_navi_speed_contorller_view"))

        # 地图缩虐图
        self.navigating_thumbnail_img = (By.XPATH, Map.RESOURCE_ID.format("portrait_tv_show_world"))

        # 比例尺
        self.navigating_scale_img = (By.XPATH, Map.RESOURCE_ID.format("map_scale"))

    def click_home(self):
        """
        点击左侧的home键

        :return:None
        """
        self.click_element(self.navigating_home_btn)

    def click_back(self):
        """
        点击左侧的back键

        :return:None
        """
        self.click_element(self.navigating_back_btn)

    def get_route_turn(self):
        """
        获取路线转向图片

        :return:获取元素
        """
        return self.find_element_o(self.navigating_route_turn_btn)

    def get_route_remaining_distance(self):
        """
        获取剩余距离

        :return:获取元素
        """
        return self.find_element_o(self.navigating_route_remaining_distance_text)

    def get_current_position(self):
        """
        获取当前位置文案

        :return:获取元素
        """
        return self.find_element_o(self.navigating_current_position_text)

    def get_remaining_distance_tip(self):
        """
        获取剩余距离提示文案

        :return:获取元素
        """
        return self.find_element_o(self.navigating_remaining_distance_tip_text)

    def get_remaining_distance(self):
        """
        获取剩余距离文案

        :return:获取元素
        """
        return self.find_element_o(self.navigating_remaining_distance_text)

    def get_route_reminder(self):
        """
        获取剩余路线提示图片

        :return:获取元素
        """
        return self.find_element_o(self.navigating_route_reminder_img)

    def click_close(self):
        """
        点击关闭键

        :return:None
        """
        self.click_element(self.navigating_close_btn)

    def click_stop(self):
        """
        点击暂停键

        :return:None
        """
        self.click_element(self.navigating_stop_btn)

    def click_double_speed(self):
        """
        点击倍数键

        :return:None
        """
        self.click_element(self.navigating_double_speed_btn)

    def get_thumbnail(self):
        """
        获得地图缩略图

        :return:获取元素
        """
        return self.find_element_o(self.navigating_thumbnail_img)

    def get_scale(self):
        """
        获得当前比例尺

        :return:获取元素
        """
        return self.find_element_o(self.navigating_scale_img)

    def is_display_map_navigating(self):
        """
        查看是否进入导航中

        :return:
        """
        return self.is_display(self.navigating_remaining_distance_tip_text)
